# Maintainer: David Runge <dvzrv@archlinux.org>

_name=diff_cover
pkgname=python-diff-cover
pkgver=7.5.0
pkgrel=2
pkgdesc="Automatically find diff lines that need test coverage"
arch=(any)
url="https://github.com/Bachmann1234/diff_cover"
license=(Apache)
depends=(python-chardet python-jinja python-pluggy python-pygments)
makedepends=(python-build python-installer python-poetry-core python-wheel)
checkdepends=(python-pytest python-pytest-mock python-tomli)
optdepends=('python-tomli: for TOML support')
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz{,.asc})
sha512sums=('3e3455fa89873554e0912a2bdf855fcc91a52ae801c1af80e4e32547a0fd5da8d5724eadddb5f7874b3dbf7f206c14b185eea4938de09dd03e72c29613a4cb1b'
            'SKIP')
b2sums=('6f6743bca81a2f3d893a19336a44d7638659eb065f31220dd74e58f063babd0d5fe49b4c729ed1c376afeabe12ec3f1996c19ac315bd08aabe8381e7dcccf675'
        'SKIP')
validpgpkeys=('54CAEABCAC2956D407348256972401BDE60128CB') # Matt Bachmann <matt.bachmann@lola.com>

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  # ignore integration and code style checks
  pytest -vv --ignore 'tests/test_integration.py' --ignore 'tests/test_violations_reporter.py' --ignore 'tests/test_clover_violations_reporter.py'
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"
}
